import request from '@/utils/request'

/**
 * 海关编码列表
 * @param {{
 *  page: number
 *  limit: number
 *  keyword: string
 * }} data
 * @returns
 */
export function hscodeList(data) {
  return request({
    url: '/tax.hscode/lists',
    method: 'post',
    data
  })
}

/**
 * 添加海关编码
 * @param {{
 *  hscode: string
 *  name: string
 *  first_unit: string
 *  second_unit: string
 *  tax_rate: number
 *  status: DEFAULT_SWITCH_VALUE
 * }} data
 * @returns
 */
export function addHscode(data) {
  return request({
    url: '/tax.hscode/handleAdd',
    method: 'post',
    data
  })
}

/**
 * 编辑海关编码
 * @param {{
 * hscode_id: number
 * hscode: string
 * name: string
 * first_unit: string
 * second_unit: string
 * tax_rate: number
 * status: DEFAULT_SWITCH_VALUE
 * }} data
 * @returns
 */
export function editHscode(data) {
  return request({
    url: '/tax.hscode/handleEdit',
    method: 'post',
    data
  })
}

/**
 * 删除海关编码
 * @param {{
 *  hscode_id: number
 *  hscode: string
 *  status: DEFAULT_SWITCH_VALUE
 * }} data
 * @returns
 */
export function deleteHscode(data) {
  return request({
    url: '/tax.hscode/handleDel',
    method: 'post',
    data
  })
}

/**
 * 切换状态
 * @param {{
 * hscode_id: number
 * hscode: string
 * status: DEFAULT_SWITCH_VALUE
 * }} data
 * @returns
 */
export function changeHscodeStatus(data) {
  return request({
    url: '/tax.hscode/handleStatus',
    method: 'post',
    data
  })
}

/**
 * 品牌维护
 * @param {{
 *  brand_id: number
 *  brand_zh: string
 *  brand_en: string
 *  handleWhere: number
 *  passWord: string
 * }} data
 * @returns
 */
export function hscodeRepair(data) {
  return request({
    url: '/brand.index/handleRepair',
    method: 'post',
    data
  })
}

/**
 * 当前编码对应词库
 * @param {{
 *  hscode_id: number
 *  hscode: string
 *  word: string
 * }} data
 * @returns
 */
export function hscodeWord(data) {
  return request({
    url: '/tax.hsword',
    method: 'post',
    data
  })
}

/**
 * 绑定词库
 * @param {{
 *  hscode_id: number
 *  word_id: number
 * }} data
 * @returns
 */
export function hscodeBindWord(data) {
  return request({
    url: '/tax.hsword/bindWord',
    method: 'post',
    data
  })
}

/**
 * 查询 海关编码已绑定词库
 * @param {{
 *  hscode_id: number
 *  keyword: string
 * }} data
 * @returns
 */
export function hscodeBindSearch(data) {
  return request({
    url: '/tax.hsword/bindSearch',
    method: 'post',
    data
  })
}

/**
 * 删除 海关编码已绑定词库
 * @param {{
 *  word_id: string
 *  hscode_id: number
 * }} data
 * @returns
 */
export function hscodeBindDelete(data) {
  return request({
    url: '/tax.hsword/bindDel',
    method: 'post',
    data
  })
}

/**
 * 搜索 海关编码未绑定的中文词库
 * @param {{
 *  page: number
 *  limit: number
 *  hscode_id: number
 *  word: string
 * }} data
 * @returns
 */
export function hscodeUnBind(data) {
  return request({
    url: '/tax.hsword/unBind',
    method: 'post',
    data
  })
}

/**
 * 加入总库 同时绑定到当前海关编码词库
 * @param {{
 *  hscode_id: number
 *  word: string
 * }} data
 * @returns
 */
export function hscodeAddWord(data) {
  return request({
    url: '/tax.hsword/addWord',
    method: 'post',
    data
  })
}
